class OptimizationPanel : public QWidget {
public:
    OptimizationPanel(QWidget* parent = nullptr) : QWidget(parent) {
        auto layout = new QVBoxLayout(this);
        
        // 创建控件
        auto qualityLabel = new QLabel("当前质量:");
        m_qualityValue = new QLabel("0.0");
        
        auto optimizeButton = new QPushButton("优化");
        
        // 添加到布局
        auto infoLayout = new QHBoxLayout;
        infoLayout->addWidget(qualityLabel);
        infoLayout->addWidget(m_qualityValue);
        
        layout->addLayout(infoLayout);
        layout->addWidget(optimizeButton);
        
        // 连接信号
        connect(optimizeButton, &QPushButton::clicked, this, &OptimizationPanel::onOptimize);
    }

private slots:
    void onOptimize() {
        if(!m_mesh)
            return;
            
        MeshOptimizer optimizer;
        if(optimizer.optimize(*m_mesh)) {
            updateQualityDisplay();
            emit meshUpdated();
        }
    }
    
    void updateQualityDisplay() {
        if(!m_mesh)
            return;
            
        double quality = MeshQuality::evaluateOverallQuality(*m_mesh);
        m_qualityValue->setText(QString::number(quality, 'f', 3));
    }

private:
    QLabel* m_qualityValue;
    MeshData* m_mesh = nullptr;
    
signals:
    void meshUpdated();
}; 